<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>签约网</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/lawyer.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>
    <style>

    </style>
</head>

<body>
    <div id="secHeader">
      <header class="header">
          <a href="javascript:void(0);" onclick="comeBack()" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a>
          <h2>消息中心</h2>
          <!-- <a href="javascript:;" class="tel_btn readed_btn">标记为已读</a> -->
      </header>
    </div>
    <section class="info_kinds">
        <div class="info">
            <ul>
                <li class="active"><a href="javascript:;">我的消息</a></li>
                <li class=""><a href="javascript:;">系统消息</a></li>
            </ul>
        </div>
    </section>

    <section class="user_info" id='bigcon'>
        <ul id='con'>
            <!-- <li class="active">
            <a href="javascript:;" onclick="aaplay('index','##')">
                <h6>系统消息</h6>
                <p>钱借给别人，但借条被担保人撕了，这钱还能要回来吗？钱借 给别人，但借条被担保人撕了，这钱还能要回来吗？</p>
                <div class="info_time">
                    <span>2019-11-18  14:57</span>
                    <span>点击查看</span>
                </div>
            </a>
        </li>

         -->

        </ul>
    </section>




</body>

<script>
    var page = 1;
    var p = '';
    var type = 1;

    apiready = function() {
      $api.fixStatusBar( $api.dom('#secHeader') );
      api.setStatusBarStyle({
          style: 'light'
      });

        api.addEventListener({
            name: 'scrolltobottom'
        }, function(ret, err) {

            toDoRequest();

        });


        toDoRequest()
    };

    function toDoRequest() {

        p = {
            token: token,
            type: type,
            page: page
        };
        //alert(JSON.stringify(p))
        api.ajax({
            url: webSiteUrl + '/app/user/smsg',
            method: 'post',
            data: {
                values: p
            }
        }, function(ret, err) {
            if (ret.code == 200) {


                html = "";
                var tj = ret.data;
                if (tj != '' && tj != null && typeof(tj) != "undefined") {

                    for (var i = 0; i < tj.length; i++) {

                        if (type == 1) {

                            if (tj[i].new == 1) {
                                html += '<li class="active">';
                            } else {
                                html += '<li>';
                            }

                            if(tj[i].icon.indexOf('http') != -1){
                              var icon = tj[i].icon;
                            }else{
                              var icon =  webSiteUrl + tj[i].icon;
                            }

                            if (tj[i].type == 1) {
                                html += '<a href="javascript:;" onclick="myorder()"><img src="' + icon + '" alt=""><div class="info"><p>' + tj[i].phone + '</p><span>您有新订单了，快去看看吧 ！</span></div><em>' + tj[i].time +
                                    '</em></a></li>';

                            } else if (tj[i].type == 2) {
                                html += '<a href="javascript:;" onclick="dtdetail(' + tj[i].tid + ')"><img src="' +icon + '" alt=""><div class="info"><p>' + tj[i].phone + '</p><span>您发布的动态有人评价了 ！</span></div><em>' + tj[i]
                                    .time + '</em></a></li>';

                            } else if (tj[i].type == 3) {

                                html += '<a href="javascript:;" onclick="mypl()"><img src="' + icon + '" alt=""><div class="info"><p>' + tj[i].phone + '</p><span>您的订单有人评价了 ！</span></div><em>' + tj[i].time +
                                    '</em></a></li>';

                            } else if (tj[i].type == 4) {
                                html += '<a href="javascript:;" onclick="mymind()"><img src="' + icon + '" alt=""><div class="info"><p>' + tj[i].phone + '</p><span>您有会员向您表示的心意，请立即查看 ！</span></div><em>' + tj[i].time +
                                    '</em></a></li>';

                            } else if (tj[i].type == 5) {
                                html += '<a onclick="fask()"><img src="' + icon + '" alt=""><div class="info"><p>' + tj[i].phone + '</p><span>您的意见已被用户采纳 ！</span></div><em>' + tj[i].time + '</em></a></li>';

                            } else if (tj[i].type == 6) {
                                html += '<a href="javascript:;" onclick="msg(' + tj[i].ask_id + ')"><img src="' + icon+ '" alt=""><div class="info"><p>' + tj[i].phone + '</p><span>您的图文咨询订单已有会员回复 ！</span></div><em>' + tj[i]
                                    .time + '</em></a></li>';
                            }else if (tj[i].type == 7) {
                                html += '<a href="javascript:;" onclick="myorder()"><img src="' + icon + '" alt=""><div class="info"><p>' + tj[i].phone + '</p><span>您的订单会员已确认完成 ！</span></div><em>' + tj[i]
                                    .time + '</em></a></li>';
                            }else if (tj[i].type == 8) {
                                html += '<a href="javascript:;" onclick="myorder()"><img src="' +icon+ '" alt=""><div class="info"><p>' + tj[i].phone + '</p><span>有会员向您支付律师费 ！</span></div><em>' + tj[i]
                                    .time + '</em></a></li>';
                            }

                        } else {

                            if (tj[i].new == 1) {
                                html += '<li class="active">';
                            } else {
                                html += '<li>';
                            }
                            html += '<a href="javascript:;"><h6>系统消息</h6><p>' + tj[i].content + '</p><div class="info_time"><span>' + tj[i].time + '</span><span  onclick="sysmsg(' + tj[i].id + ')">点击查看</span></div></a></li>';


                        }
                    }
                }
                $('#con').html(html);
                /*if(page==1){
                    $('#con').html(html);
                }else{
                    $('#con').append(html);
                }
                page++;*/
                know();
            } else {
                if (page == 1) {
                    $('#con').html('<p style="text-align:center">暂无数据</p>');
                }

            }
        });

    }
    //查看咨询
    function fask(){
      api.openWin({
          name: 'myanswer',
          url: 'myanswer.html',

          reload: true,
          pageParam: {

          }
      });
    }
    //查看我的评论
    function mypl() {
        api.openWin({
            name: 'mypl',
            url: 'mypl.html',
            reload: true,
            pageParam: {

            }
        });
    }
    //查看留言
    function msg(id) {
        api.openWin({
            name: 'viewmessage',
            url: 'viewmessage.html',
            reload:true,
            pageParam: {
                id: id
            }
        });

    }


    function know() {
        p = {
            token: token
        };
        api.ajax(webSiteUrl + '/app/user/know', p, function(ret) {
            if (ret.code == 200) {

            }
        });
    }

    $('.info li').click(function() {
            $(this).addClass('active').siblings().removeClass('active');

            $('#bigcon ul').empty()
            if ($(this).index() == 0) {
                $('#bigcon').addClass('user_info').removeClass('system_info');
            } else {
                $('#bigcon').addClass('system_info').removeClass('user_info');
            }

            page = 1;
            type = parseInt($(this).index() + 1);
            toDoRequest();
        })
        //点赞
    $(document).on('click', '.lawyers_list dl dd .lawyers_fabulous', function() {

        if (!$(this).hasClass('active')) {
            $(this).addClass('active');
            $(this).html(parseInt($(this).text()) + 1)
        }
    });

    function mymind(id) {
        api.openWin({
            name: 'personal_mind',
            url: 'personal_mind.html',
            reload:true,
            pageParam: {
                id: id
            }
        });
    }


    function sysmsg(id) {
        api.openWin({
            name: 'msg_detail',
            url: 'msg_detail.html',
            reload:true,
            pageParam: {
                id: id
            }
        });
    }

    function myorder() {
        api.openWin({
            name: 'personal_myOrder',
            url: 'personal_myOrder.html',
            reload:true,
            pageParam: {

            }
        });

    }

    /**
     *该方法用来返回页面
     *  **/
    function comeBack() {
        api.historyBack({}, function(ret, err) {
            if (!ret.status) {
                api.closeWin();
            }
        });
    }
    //标记为已读
    $(".readed_btn").click(function() {
        $('.system_info ul li').removeClass('active');
        $('.user_info ul li').removeClass('active');
    })
</script>

</html>
